package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import static com.fywsy.fyweb.utils.RestTemplateUtil.sendPostForm;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(17)
public class AMojiGameStrategy extends BaseGameStrategy {

    public static final String MAIL = "http://114.66.45.45:30381/gmss/user/gmquery.php";

    /**
     * 充值-不计入累充
     * @param item
     * @return
     */
    @GongnengMethod(1701)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type","charge");
        params.add("checknum","diyao88");
        params.add("uid",item.uid);
        params.add("chargetype",item.itemId);
        params.add("chargenum",item.number);
        params.add("qu","1");
        return RestTemplateUtil.sendPostForm(MAIL,params);
    }

    /**
     * 充值-计入累充
     * @param item
     * @return
     */
    @GongnengMethod(1702)
    public String pay2(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type","gift");
        params.add("checknum","diyao88");
        params.add("uid",item.uid);
        params.add("gifttype",item.itemId);
        params.add("qu","1");
        return RestTemplateUtil.sendPostForm(MAIL,params);
    }

    /**
     * type: mail
     * uid: 4555786934469198637
     * item: 200054
     * num: 2
     * qu: 1
     * checknum: diyao88
     * @param item
     * @return
     */
    @GongnengMethod(1703)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("type","mail");
        params.add("checknum","diyao88");
        params.add("uid",item.uid);
        params.add("item",item.itemId);
        params.add("num",item.number);
        params.add("qu","1");
        return RestTemplateUtil.sendPostForm(MAIL,params);
    }

    @GongnengMethod(1704)
    public String gongneng(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("qu","1");
        params.add("checknum","diyao88");
        params.add("uid",item.uid);
        if("1".equals(item.itemId)) { //设置等级
            params.add("type","sl");
            params.add("typenum",item.number);
        } else if("2".equals(item.itemId)) {    //跳关
            params.add("type","passlevel");
            params.add("typenum",item.number);
        } else if ("3".equals(item.itemId)) {   //清空背包
            params.add("type","qiangli");
        }

        return RestTemplateUtil.sendPostForm(MAIL,params);
    }
}

